package org.goldfish.jstl_playground;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

@WebServlet(name = "helloServlet", value = "/hello")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        List<BookBean>books=new ArrayList<>();
        books.add(new BookBean("1","Java",20));
        books.add(new BookBean("2","C++",30));
        books.add(new BookBean("3","Python",40));
        request.setAttribute("books",books);
        System.out.println(books);
        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }

    public void destroy() {
    }
}